clear all
set matsize 800
set more off


use "${datapath}/fascism_db.dta",clear

* standardize dependent and independent vars
foreach var of varlist fascist_violence-strike_agr_1920 lpop1911-volunteers1866_pop rain1918-rain_var {
egen z_`var'=std(`var')
}

* relabel them
run "labels.do"


*********************
******Figure 5*******
*********************
local cntls_spec1 "z_lpop1911 z_lpop2 z_lpop3 z_lpop4 z_sh_pop_1911_be6 d_reg* province*"
local cntls_spec2 "`cntls_spec1' z_larea z_centre_alt z_max_alt"
local cntls_spec3 "`cntls_spec2' z_psu1913_vv"
local cntls_spec4 "`cntls_spec3' z_veterans74_95 z_veterans96_00 z_ard_vol_pop6m z_cruent_d z_army_suppliers_d"
local cntls_spec5 "`cntls_spec4' z_dlab z_shcrop z_landlord_ass"
local cntls_spec6 "`cntls_spec5' z_ind_workers z_ind_firms z_literacy z_elites z_bourgeoisie"

qui reg z_psu1919_vv z_foots_pop6m `cntls_spec1'
predict psu1919hat, xb

sum psu1919hat,d
g nt1919 = psu1919hat<r(p25)
g nt1913 = psu_cand1913==0

eststo clear


foreach depvar of varlist z_fascist_violence z_fascist_branch z_fascist1921_vv z_fascist1924_vv {
foreach i of numlist 1 4 6 {

eststo: qui reg `depvar' z_foots_pop6m `cntls_spec`i'', cl(circondario1921)
eststo: qui reg `depvar' z_foots_pop6m `cntls_spec`i'' if nt1919==1, cl(circondario1921)
eststo: qui reg `depvar' z_foots_pop6m `cntls_spec`i'' if nt1913==1, cl(circondario1921)
}
}


#delim ;
coefplot 	(est1, offset(.15)) (est4) (est7, offset(-.15)),											bylabel(Full Sample) 	||
			(est2, offset(.15)) (est5) (est8, offset(-.15)),											bylabel(Predicted Socialist Share in Q1 in 1919)	||
			(est3, offset(.15)) (est6) (est9, offset(-.15)), 											bylabel(No Socialists in 1913) 		||,
			bycoefs plotlabels("1st Specification" "4th Specification" "6th Specification") keep(z_foots_pop6m) xline(0) msymbol(s) msize(small) ci(95) ciopts(recast(rcap))
			plotregion(color(white)) xlabel(-.1(.05).1, nogrid labsize(*2.5)) ylabel(, labsize(*2.5)) xscale(lcolor("black") fextend) yscale(lcolor("black")  fextend)  legend(off) aspectratio(.9) ysize(2.5);
			
#delim cr

graph export "${outpath}/fig5a.png", replace width(4000)



#delim ;

coefplot 	(est10, offset(.2)) (est13) (est16, offset(-.2)),											bylabel(Full Sample) 	||
			(est11, offset(.2)) (est14) (est17, offset(-.2)),											bylabel(Predicted Socialist Share in Q1 in 1919)	||
			(est12, offset(.2)) (est15) (est18, offset(-.2)), 											bylabel(No Socialists in 1913) 		||,
			bycoefs plotlabels("1st Specification" "4th Specification" "6th Specification") keep(z_foots_pop6m) xline(0) msymbol(s) msize(vsmall) ci(95) ciopts(recast(rcap)) plotregion(color(white)) xlabel(-.1(.05).1 , nogrid labsize(*2.5)) ylabel(, labsize(*2.5)) xscale(lcolor("black") fextend) yscale(lcolor("black")  fextend)  legend(off)   aspectratio(.9) ysize(2.5);
			
#delim cr
graph export "${outpath}/fig5b.png", replace width(4000)

#delim ;

coefplot 	(est19, offset(.2)) (est22) (est25, offset(-.2)) ,											bylabel(Full Sample)	 			||
			(est20, offset(.2)) (est23) (est26, offset(-.2)) ,											bylabel(Predicted Socialist Share in Q1 in 1919) 	||
			(est21, offset(.2)) (est24) (est27, offset(-.2)) , 											bylabel(No Socialists in 1913) 		||,
			bycoefs plotlabels("1st Specification" "4th Specification" "6th Specification") keep(z_foots_pop6m) xline(0) msymbol(s) msize(vsmall) ci(95) ciopts(recast(rcap)) plotregion(color(white)) xlabel(-.1(.05).1 , nogrid labsize(*2.5)) ylabel(, labsize(*2.5)) xscale(lcolor("black") fextend) yscale(lcolor("black")  fextend)  legend(off)  aspectratio(.9) ysize(2.5) ;
			
#delim cr
graph export "${outpath}/fig5c.png", replace width(4000)

#delim ;

coefplot 	(est28, offset(.2)) (est31) (est34, offset(-.2))  ,											bylabel(Full Sample) 				||
			(est29, offset(.2)) (est32) (est35, offset(-.2)),											bylabel(Predicted Socialist Share in Q1 in 1919) 	||
			(est30, offset(.2)) (est33) (est36, offset(-.2)), 											bylabel(No Socialists in 1913) 		||,
		
			bycoefs plotlabels("1st Specification" "4th Specification" "6th Specification") keep(z_foots_pop6m) xline(0) msymbol(s) msize(vsmall) ci(95) ciopts(recast(rcap)) plotregion(color(white)) xlabel(-.1(.05).1 , nogrid labsize(*2.5)) ylabel(, labsize(*2.5)) xscale(lcolor("black") fextend) yscale(lcolor("black")  fextend)  legend(off)aspectratio(.9) ysize(2.5) ;
			
#delim cr

graph export "${outpath}/fig5d.png", replace width(4000)

eststo clear
